<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    用户名:<input type="text" name="name">
    <p id="pp"></p>
    <script>
       var inp = document.getElementsByName('name')[0];
       var pp = document.getElementById('pp');
        inp.onblur = function(){
            var xhr = new XMLHttpRequest();
            xhr.open('post','3.php',true);
            xhr.setRequestHeader('Content-type','application/x-www-form-urlencoded');
            xhr.send('name='+inp.value);
            xhr.onreadystatechange = function(){
                if(this.readyState == 4){
                    pp.innerHTML = this.responseText;
                }
            }
        }
    </script>
</body>
</html>